<template>
	<view class="container">
		<view v-if="Object.keys(dataList).length > 0" class="u-padding-20 z-b-r white-bg z-bg-color z-white-font">
			<view class="z-font-lg u-padding-bottom-20" style="font-weight: bold;border-bottom: 1rpx solid #C0C0C0;">
				项目基本信息
			</view>
			<view class="u-margin-bottom-20 u-margin-top-30">
				<text>项目名称：{{ dataList.project_name}}</text>
			</view>
			<view class="u-margin-bottom-20">
				<text>项目地址：{{ dataList.project_address}}</text>
			</view>
			<view class="u-margin-bottom-20">
				<text>项目开始日期：{{ dataList.project_begin_date}}</text>
			</view>
			<view class="u-margin-bottom-20">
				<text>项目经理姓名：{{ dataList.pm_name}}</text>
			</view>
			<view class="u-margin-bottom-20">
				<text>项目经理电话：{{ dataList.pm_phone}}</text>
			</view>
		</view>
		<view v-else>
			<empty-data tipText="无项目"></empty-data>
		</view>

		<view class="u-padding-20 z-b-r white-bg u-margin-top-20">
			<view class="u-flex u-col-center u-row-between">
				<view class="z-font-lg" style="font-weight: bold">工作量信息</view>
				<view class="u-padding-bottom-20 u-margin-right-30" style="color: #ccc;">
					<view>总计工作天数：{{ jobInfoStatistics.signCountDay || "无数据" }}</view>
					<view>总计钻孔深度：{{ jobInfoStatistics.drillDeepCount || "无数据" }}</view>
				</view>
			</view>
			<wx-load-more ref="loadMore" @provider="provider" :pageSize="10">
				<template v-slot:list="{ items }">
					<view style="border: 1rpx solid #C0C0C0;">
						<view class="th-head u-flex u-row-around">		
							<view class="th-head-row th-head-row1">孔深</view>
							<view class="th-head-row th-head-row2">孔号</view>
							<view class="th-head-row th-head-row3">打卡日期</view>
							<view class="th-head-row th-head-row4">状态</view>
						</view>
						<view 
						class="td-body u-flex u-row-around" 
						v-for="(item,index) in items" :key="index" 
						>
							<view class="td-body-row td-body-row1">{{ item.hole_deep}}</view>
							<view class="td-body-row td-body-row2">{{ item.hole_mark }}</view>
							<view class="td-body-row td-body-row3">{{ item.date }}</view>
							<view class="td-body-row td-body-row4">
								<u-tag 
									size="mini" 
									:text="item.signinStatus === 1 ? '通过' : (item.signinStatus === 0 ? '待审核' : '未通过')" 
									:type="item.signinStatus === 1 ? 'success' : (item.signinStatus === 0 ? 'info' : 'error')" 
									/>
							</view>
						</view>
					</view>
				</template>
			</wx-load-more>
		</view>
	</view>
</template>

<script>
	import wxLoadMore from '@/components/wx-load-more/wx-load-more.vue';
	import {mapState} from "vuex"
	export default {
		components: {
			wxLoadMore
		},
		data() {
			return {
				projectStatus: 0,
				dataList: {},
				workerLists: [],
				jobInfoStatistics:{}
			};
		},
		computed: {
			...mapState({
				token: "token",
				wkID: "wkID"
			})
		},
		onLoad(params) {
			this.projectStatus = params.projectStatus;
		},
		mounted() {
			this.$refs.loadMore.reLoadData();
		},
		onReachBottom() {
			this.$refs.loadMore.reachBottom()
		},
		methods: {
			async provider(e) {
				let {pageNo,pageSize} = e;
				let {token,wkID,projectStatus} = this;
				this.$loading("正在加载")
				let res = await this.$network({
					api: "main",
					data: {
						action:"wkProjectAdmin/getUnderwayProject",
						data:{
							token,
							wkID,
							projectStatus: parseInt(projectStatus)
						}
					}
				})
				
				if (res.status === 0) {
					this.dataList = res.data[0];
					//当前项目里面当前员工的工作量统计
					this.dataList.worker_ids.forEach(item => {
						if(item.wkID == wkID){
							this.jobInfoStatistics = item;
						}
					})
					// 获取工作信息
					let workerInfos = await this.$network({
						api: "main",
						data: {
							action:"wkProjectAdmin/getWorkerInfo",
							data:{
								token,
								wkID,
								projectID: this.dataList._id,
								pageNo,
								pageSize
							}
						}
					})
				 
					uni.hideLoading();
					if (workerInfos.status === 0) {
						this.$refs.loadMore.pushData(workerInfos.data);
					} else if (workerInfos.status === 1) {
						this.$refs.loadMore.pushData([]);
					}
				} else {
					uni.hideLoading();
					this.$refs.loadMore.pushData([]);
				}
			},
			resData(){}
		}
	}
</script>

<style lang="scss">
	.workload{
		line-height: 60rpx;
		text-align: left;
	}
	.td-body-row,
	.th-head-row{
		line-height: 60rpx;
		text-align: center;
	}
	.td-body{
		border-bottom: 1rpx solid #C0C0C0;
	}
	.td-body-row1,
	.th-head-row1,
	.td-body-row2,
	.th-head-row2,
	.td-body-row4,
	.th-head-row4
	{
		width: 20%;
	}
	.td-body-row3,
	.th-head-row3
	{
		width: 40%;
	}
	.th-head{
		font-weight: bold;
		background: #edece8;
		line-height: 80rpx;
		text-align: center;
	}
	.wkinfo-item{
		line-height: 60rpx;
		font-weight: bold;
	}
</style>
